import axios from 'axios';
import { MoviesModel, MoviesBeanMovies } from '../model/MoviesModel';

export const fetchMoviesData = async (): Promise<MoviesModel> => {
  const response = await axios.get('https://reactnative.dev/movies.json');

  const movieDataArray: MoviesBeanMovies[] = response.data.movies.map(
    (movieData: any) => ({
      id: movieData.id,
      title: movieData.title,
      releaseYear: movieData.releaseYear,
    }),
  );
  return {
    title: response.data.title,
    description: response.data.description,
    movies: movieDataArray,
  };
};
export const fetchMovieDetails = async (id: string): Promise<string> => {
  return `电影详情${id}`;
};
